package com.guigu.www.erp.dengtao.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.www.erp.common.pojo.DFile;
import com.guigu.www.erp.common.pojo.PageVo;
import com.guigu.www.erp.common.pojo.SCell;
import com.guigu.www.erp.dengtao.dao.SCellMapper;
import com.guigu.www.erp.dengtao.service.SCellService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class SCellServiceImpl implements SCellService {
    @Autowired
    SCellMapper sCellMapper;
    @Override
    public String select() {
        return sCellMapper.selemax();
    }

    @Override
    public void add(SCell sCell) {
        sCellMapper.insertSelective(sCell);
    }

    @Override
    public PageVo<SCell> selctfh(Map<String, String> map) {
        PageHelper.startPage(Integer.valueOf(map.get("pageNum")==null?1:Integer.valueOf(map.get("pageNum"))),
                Integer.valueOf(map.get("pageSize")==null?2:Integer.valueOf(map.get("pageSize"))));

        List<SCell> dFileList=sCellMapper.aqkcseleAll();
        PageInfo<SCell> ages=new PageInfo(dFileList);
        long total = ages.getTotal();
        List<SCell> list=ages.getList();

        return new PageVo<SCell>(total,list);
    }

    @Override
    public void btg(String id) {
        sCellMapper.btg(id);
   }

    @Override
    public void tg(String id,String sj) {
        sCellMapper.tg(id,sj);
    }

    @Override
    public PageVo<SCell> selctbg(Map<String, String> map) {
        PageHelper.startPage(Integer.valueOf(map.get("pageNum")==null?1:Integer.valueOf(map.get("pageNum"))),
                Integer.valueOf(map.get("pageSize")==null?2:Integer.valueOf(map.get("pageSize"))));

        List<SCell> dFileList=sCellMapper.aqkcseleAllbg();
        PageInfo<SCell> ages=new PageInfo(dFileList);
        long total = ages.getTotal();
        List<SCell> list=ages.getList();

        return new PageVo<SCell>(total,list);
    }

    @Override
    public void put(SCell sCell) {
        System.out.println(sCell);
        sCellMapper.put(sCell);
    }

    @Override
    public PageVo<SCell> cxsy(Map<String, String> map) {
        SCell sCell=new SCell();

        PageHelper.startPage(Integer.valueOf(map.get("pageNum") == null ? 1 : Integer.valueOf(map.get("pageNum"))),
                Integer.valueOf(map.get("pageSize") == null ? 2 : Integer.valueOf(map.get("pageSize"))));

        sCell.setRegisterTime(map.get("registerTime") == null ? "" : map.get("registerTime"));
        sCell.setChecker(map.get("checker") == null ? "" : map.get("checker"));


        List<SCell> dFileList = sCellMapper.cxsy(sCell);
        PageInfo<SCell> ages = new PageInfo(dFileList);
        long total = ages.getTotal();
        List<SCell> list = ages.getList();
        return new PageVo<SCell>(total,list);
    }
}
